//
//  TabBarViewController.m
//  Distributor
//
//  Created by 主事丫环 on 2019/5/5.
//  Copyright © 2019 主事丫环. All rights reserved.
//

#import "TabBarViewController.h"
#import "DISACenterViewController.h"
#import "DISProfitViewController.h"

#import "DISBMProfitViewController.h"
#import "DISBMshopViewController.h"
#import "DISBMCenterViewController.h"

#import "AOrderMallRootVC.h" //省级产品展示
#import "BOrderMallRootVC.h"//市县级产品展示

@interface TabBarViewController ()

@end

@implementation TabBarViewController
-(void)viewWillAppear:(BOOL)animated
{
    // 适配iOS13导致的bug
    if (@available(iOS 13.0, *)) {
        self.tabBar.tintColor = [UIColor colorWithHexString:@"#70BE68"];
       
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    NSString *set = [USER_DEFAULT objectForKey:@"level"];
    if ([set integerValue] == 1) {
        //A级经销商
        [self Ajidailis];
    } else if ([set integerValue] == 2) {
       //b有收益
        [self BjidailisBMoney];

    } else if ([set integerValue] == 3) {
        //b没收益
      
    }
}

-(void)BjidailisBMoney{
    DISBMProfitViewController *vc1 = [[DISBMProfitViewController alloc] init];
    [self addOneChildVc:vc1 title:@"收益" imageName:@"tabwodeshouyi" selectedImageName:@"tabwodeshouyi1"];
    
    
//    DISBMshopViewController *vc2 = [[DISBMshopViewController alloc] init];
//    [self addOneChildVc:vc2 title:@"店铺" imageName:@"tabDianpu" selectedImageName:@"tabDianpu1"];
    
    BOrderMallRootVC *vc3 = [[BOrderMallRootVC alloc] init];
    [self addOneChildVc:vc3 title:@"产品展示" imageName:@"tabordermall" selectedImageName:@"tabordermall1"];
    
    DISBMCenterViewController *vc4 = [[DISBMCenterViewController alloc] init];
    [self addOneChildVc:vc4 title:@"我的" imageName:@"tabwode" selectedImageName:@"tabwode1"];
}

-(void)Ajidailis{
    DISProfitViewController *vc1 = [[DISProfitViewController alloc] init];
    [self addOneChildVc:vc1 title:@"收益" imageName:@"tabwodeshouyi" selectedImageName:@"tabwodeshouyi1"];
    AOrderMallRootVC *vc2 = [[AOrderMallRootVC alloc] init];
    [self addOneChildVc:vc2 title:@"产品展示" imageName:@"tabordermall" selectedImageName:@"tabordermall1"];
    DISACenterViewController *vc3 = [[DISACenterViewController alloc] init];
    [self addOneChildVc:vc3 title:@"我的" imageName:@"tabwode" selectedImageName:@"tabwode1"];
}

- (void)addOneChildVc:(UIViewController *)childVc title:(NSString *)title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName {
    UIImage *normalImage = [UIImage imageNamed:imageName];
    UIImage *selectedImage = [[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    childVc.tabBarItem = [[UITabBarItem alloc]initWithTitle:title image:normalImage selectedImage:selectedImage];
    [childVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#70BE68"]} forState:UIControlStateSelected];
    
    //设置tabbar白色不透明背景
    //UIView *bgView = [[UIView alloc] initWithFrame:self.tabBar.bounds];
    //bgView.backgroundColor = [UIColor whiteColor];
    //[self.tabBar insertSubview:bgView atIndex:0];
    
    BaseNavViewController *nav = [[BaseNavViewController alloc] initWithRootViewController:childVc];
    [self addChildViewController:nav];
}
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
 
}
@end
